import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
export type BannerResult = {
  page: number;
  pagesize: number;
  success: boolean;
  code: number;
  token: string;
  msg: string;
  data: {
    data: any[];
    total: number;
    page: number;
    pagesize: number;
  };
};
/**公司列表*/
export const companyList = (data?: object) => {
  const url = `admin/company/list?page=${data.page}&pagesize=${data.pagesize}&role_id=${data.role_id}&admin_id=${data.admin_id}&action=${data.action}`;
  return http.request<BannerResult>("get", baseUrlApi(url), {
    data
  });
};
// 公司添加
export const companyInsert = (data?: object) => {
  return http.request<BannerResult>(
    "post",
    baseUrlApi("admin/company/insert"),
    {
      data
    }
  );
};

// 公司删除
export const companyDelete = (data?: object) => {
  return http.request<BannerResult>(
    "post",
    baseUrlApi("admin/company/delete"),
    {
      data
    }
  );
};

// 下拉框展示列表
export const peopleSelect = (data?: object) => {
  return http.request<BannerResult>(
    "get",
    baseUrlApi(`admin/people/select?name=${data.name}`),
    {
      data
    }
  );
};

// 公司修改
export const companyUpdate = (data?: object) => {
  return http.request<BannerResult>(
    "post",
    baseUrlApi("admin/company/update"),
    {
      data
    }
  );
};
//公司股东添加
export const companyShareInsert = (data?: object) => {
  return http.request<BannerResult>(
    "post",
    baseUrlApi("admin/company/share/insert"),
    {
      data
    }
  );
};
// // 公司股东修改
// export const companyShareUpdate = (data?: object) => {
//   return http.request<BannerResult>(
//     "post",
//     baseUrlApi("admin/company/share/update"),
//     {
//       data
//     }
//   );
// };
// 公司股东修改 更新
export const companyShareUpdate = (data?: object) => {
  return http.request<BannerResult>(
    "post",
    baseUrlApi("admin/company/share/update"),
    {
      data
    }
  );
};

// 公司管理列表
export const companySelect = (data?: object) => {
  return http.request<BannerResult>(
    "get",
    baseUrlApi(
      `admin/company/select?name=${data.name}&admin_id=${data.admin_id}`
    ),
    {
      data
    }
  );
};

// 下拉框展示列表贷款类型
export const selectType = (data?: object) => {
  return http.request<BannerResult>(
    "get",
    baseUrlApi(`admin/type/select?name=${data.name}`),
    {
      data
    }
  );
};

// 公司信息
export const gongsi = (data?: object) => {
  return http.request<BannerResult>(
    "get",
    baseUrlApi(`index/juhe/gongsi?keyword=${data.keyword}`),
    {
      data
    }
  );
};

// 股东信息
export const gudong = (data?: object) => {
  return http.request<BannerResult>(
    "get",
    baseUrlApi(`index/juhe/gudong?keyword=${data.keyword}`),
    {
      data
    }
  );
};
// 公司股东添加
export const shareInsert = (data?: object) => {
  return http.request<BannerResult>(
    "post",
    baseUrlApi(`admin/company/share/insert`),
    {
      data
    }
  );
};
// 抵押物列表
export const collateralSelect = (data?: object) => {
  return http.request<BannerResult>(
    "get",
    baseUrlApi(`admin/collateral/select?collateral=${data.collateral}`),
    {
      data
    }
  );
};
// 担保人列表
export const securitySelect = (data?: object) => {
  return http.request<BannerResult>(
    "get",
    baseUrlApi(`admin/security/select?name=${data.name}`),
    {
      data
    }
  );
};
// 使用单位列表
export const useunitSelect = (data?: object) => {
  return http.request<BannerResult>("get", baseUrlApi(`admin/useunit/select`), {
    data
  });
};
